/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#ifndef NCSI_MELLANOX_H
#define NCSI_MELLANOX_H

#include <stdint.h>

#define OEM_MLNX_GET_TEMP_CMD           0x13
#define OEM_MLNX_GET_TEMP_PARA          0x02
#define OEM_MLNX_GET_PF_MAC_CMD         0x00
#define OEM_MLNX_GET_PF_MAC_PARA        0x00
#define OEM_MLNX_GET_PORT_ID_CMD        0x00
#define OEM_MLNX_GET_PORT_ID_PARA       0x27
#define OEM_MLNX_RESET_NCI_CMD          0x12
#define OEM_MLNX_RESET_NIC_PARA         0x0A
#define OEM_MLNX_GET_LLDP_CMD           0x00
#define OEM_MLNX_GET_LLDP_PARA          0x2E
#define OEM_MLNX_SET_LLDP_CMD           0x01
#define OEM_MLNX_SET_LLDP_PARA          0x2E

#pragma pack(1)
typedef struct oem_mlnx_common_rsp {
    uint16_t response_code;
    uint16_t reason_code;
    uint32_t manufacturer_id;
    uint8_t reserved;
    uint8_t command_id;
    uint8_t parameter;
    uint8_t optional_data;
} oem_mlnx_common_rsp_t;

#define OEM_MLNX_TEMP_RSP_MIN_LEN 12
typedef struct oem_mlnx_temp_rsp {
    oem_mlnx_common_rsp_t public_rsp_header;
    uint8_t                pad_mms;
    uint8_t                max_meas_temp;
    uint8_t                max_operating_temp;
    uint8_t                cur_temp;
    std::vector<uint8_t>   extra_desc;
} oem_mlnx_temp_rsp_t;

#define OEM_MLNX_MAC_ADDR_RSP_LEN 20
typedef struct oem_mlnx_mac_addr_rsp {
    oem_mlnx_common_rsp_t public_rsp_header;
    uint8_t                 mac_addr[6];
    uint8_t                 reserved[2];
    uint32_t                check_sum;
} oem_mlnx_mac_addr_rsp_t;

#define OEM_MLNX_PORT_ID_RSP_LEN 28
typedef struct oem_mlnx_port_id_rsp {
    oem_mlnx_common_rsp_t public_rsp_header;
    uint8_t                 mac_addr[6];
    uint8_t                 reserved[2];
    uint8_t                 port_guid[8];
    uint32_t                check_sum;
} oem_mlnx_port_id_rsp_t;

#define OEM_MLNX_RESET_NIC_LEN 12
typedef struct oem_mlnx_reset_nic_rsp {
    oem_mlnx_common_rsp_t public_rsp_header;
    uint32_t                check_sum;
} oem_mlnx_reset_nic_rsp_t;

#define OEM_MLNX_LLDP_RSP_LEN 16
typedef struct oem_mlnx_lldp_rsp {
    oem_mlnx_common_rsp_t public_rsp_header;
    uint8_t                 reserved[3];
    uint8_t lldp_dcbx     : 1;          // 位0: DCBX使能
    uint8_t lldp_rx_mode  : 2;          // 位1-2: LLDP接收模式 
    uint8_t lldp_tx_mode  : 2;          // 位3-4: LLDP发送模式  
    uint8_t reserved_bits : 3;       
    uint32_t                check_sum;
} oem_mlnx_lldp_rsp_t;


#pragma pack()

#endif // NCSI_MELLANOX_H 